<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户信息</title>
<style>
table {
	border-left: 1px #0000FF solid;
	border-top: 1px #0000FF solid;
}

th, td {
	border-right: 1px #0000FF solid;
	border-bottom: 1px #0000FF solid;
}

.noborder {
	border: none;
	border-bottom: none;
	border-right: none;
}
</style>
<script type="text/javascript">
	function time() {
		document.getElementById("time").innerHTML = new Date().toLocaleString();
	};
	setInterval("time()", 1000)
</script>
</head>
<body onload="time()">

	<c:if test="${not empty cookie[username].value }">
		<c:set value="${cookie[username].value }" var="username"
			scope="session"></c:set>
	</c:if>


	<c:if test="${empty sessionScope.username }">
		<c:redirect url="./index.jsp">
			<c:param name="error" value="nologin"></c:param>
		</c:redirect>
	</c:if>

	<table width="750" border="0" align="center" cellspacing="0"
		class="noborder">
		<tr>
			<td height="50" colspan="3" class="noborder">公司logo</td>
		</tr>
		<tr>
			<td width="116" class="noborder">欢迎您，${sessionScope.username }</td>

			<td width="79" class="noborder"><input type="button"
				value="安全退出" onclick="window.location.replace('./LogOut')" /></td>

			<td width="541" align="right" class="noborder">当前时间：<span
				id="time"></span></td>
		</tr>
	</table>
	<br />
	<div align="center" style="font-size: 20px">用户信息列表页面</div>
	<br />
	<table width="750" border="0" align="center" cellspacing="0">
		<tr style="background-color: #999900">
			<th width="63" align="center">用户名</th>
			<th width="58" align="center">性别</th>
			<th width="89" align="center">生日</th>
			<th align="center">电话</th>
			<th width="108" align="center">地址</th>
			<th align="center">注册时间</th>
			<th width="110" align="center">操作</th>
		</tr>

		<c:set value="${requestScope.list }" var="list"></c:set>

		<%--
			System.out.println("list页面拿到的数据："
					+ pageContext.getAttribute("list"));
		--%>

		<c:forEach items="${list }" var="ub">
			<tr>
				<td align="center">${ub.username }</td>
				<td width="58" align="center">${ub.gender }</td>
				<td align="center">${ub.birth }</td>
				<td width="106" align="center">${ub.phone }</td>
				<td align="center">${ub.address }</td>
				<td width="201" align="center">${ub.regdate }</td>
				<td align="center"><input type="button" value="修改"
					onclick="window.location.replace('./updateuser.jsp?username=${ub.username}')" />
					<input type="button" value="删除"
					onclick="window.location.replace('./DeleteUser?username=${ub.username}')" /></td>
			</tr>
		</c:forEach>

		<c:set value="${requestScope.pageTotal }" var="pageTotal"></c:set>
		<c:set value="${requestScope.pageNow }" var="pageNow"></c:set>

		<%--System.out.println("pageNow" + pageContext.getAttribute("pageNow")); --%>

	</table>
	<br />
	<table align="center" class="noborder">
		<tr>
			<td class="noborder"><input type="button" value="首页"
				onclick="window.location.replace('./UserList?page=1')"></td>
			<td class="noborder"><input type="button" value="上一页"
				onclick="window.location.replace('./UserList?page=${pageNow == 1 ? 1 : pageNow - 1}')"></td>

			<c:forEach begin="1" end="${pageTotal }" var="i">

				<td class="noborder"><input type="button" value="${i }"
					onclick="window.location.replace('./UserList?page=${i}')"></td>

			</c:forEach>
			<td class="noborder"><input type="button" value="下一页"
				onclick="window.location.replace('./UserList?page=${pageNow == pageTotal ? pageTotal :pageNow + 1}')"></td>
			<td class="noborder"><input type="button" value="尾页"
				onclick="window.location.replace('./UserList?page=${pageTotal}')"></td>
		</tr>
	</table>
</body>
</html>